////////////////////////////////////////
// 				Information			  //
////////////////////////////////////////

// Investor Memory (Katrin Gödker, Peiran Jiao, Paul Smeets)
// Replication code for results from Experiment 2

////////////////////////////////////////
// 				Settings			  //
////////////////////////////////////////

// Stata settings:
version 15

// Import file: Use Data_Experiment2.dta

////////////////////////////////////////
// 				Dataset 			  //
////////////////////////////////////////

// Unique subject IDs are generated for clarity, pseudonymized lab IDs are deleted.

// Treatment variable
// Treatment == 1 if subject is in Delay condition; Treatment == 0 if subject is in Immediate condition

// Conditions
gen Cond = .
replace Cond = 1 if Condition == "baseline"
replace Cond = 2 if Condition == "high"
replace Cond = 3 if Condition == "default"

// Variable in order to compare high stake to baseline condition
gen base_stake = .
replace base_stake = 1 if Cond == 2
replace base_stake = 0 if Cond == 1

// Memory bias
gen MemoryBiasPos = Recall_pos - True_pos
gen MemoryBiasNeg = Recall_neg - True_neg

// Reinvestment: Keep_stock == 1 if subjects reinvested in stock in Task 2 and 0 otherwise

// Mechansim variables (self-deceptive enhancement)
destring Self_deceptive_1, replace
destring Self_deceptive_2, replace
destring Self_deceptive_3, replace

gen SDE = (Self_deceptive_1 + Self_deceptive_2 + Self_deceptive_3) / 3

// SDE: average is 3.47
gen SDE_high = 0
replace SDE_high = 1 if SDE >= 3.47

// Variable names for tables
label variable base_stake "Treatment (High Stakes)"

////////////////////////////////////////
// 				Analyses 			  //
////////////////////////////////////////

// TABLE 6
// Memory bias in delay condition (column 1)
ttest MemoryBiasPos == 0 if Treatment == 1 & Cond == 1
ttest MemoryBiasPos == 0 if Treatment == 1 & Cond == 2
ttest MemoryBiasPos == 0 if Treatment == 1 & Cond == 3

// Treatment effect (column 2)
ttest MemoryBiasPos if Cond == 1, by (Treatment)
ttest MemoryBiasPos if Cond == 2, by (Treatment)
ttest MemoryBiasPos if Cond == 3, by (Treatment)

// TABLE 7
eststo clear
eststo: xi: reg MemoryBiasPos base_stake if SDE_high == 1
eststo: xi: reg MemoryBiasPos base_stake if SDE_high == 0
esttab using reg_SDE.tex,  ///
star(* 0.10 ** 0.05 *** 0.01)  b(3) se(2) label mtitles("Memory Bias - High SDE" "Memory Bias - Low SDE")  ///
replace stats(N r2,  fmt(%12.0fc %12.2fc) labels("N" "$ R^2 $")) drop() nogaps tex prehead(`"{"' \begin{scriptsize} `"\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}"' \begin{tabular}{l*{@E}{l}} \toprule) posthead("\midrule") prefoot("\midrule") postfoot(`"\bottomrule"'  \end{tabular} \end{scriptsize} }) 
